#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "SDL2/SDL.h"
#include "SDL2/SDL_ttf.h"

#define isCellLive(x, y) &cell->old_cell_store[x][y] && cell->old_cell_store[x][y]

using namespace std;

typedef struct Cells {
	SDL_Rect cell_panel[24][24];
	Uint8 old_cell_store[24][24];
	Uint8 cell_store[24][24];
} Cell;

typedef struct Control {
	SDL_Rect reset_rect;    
	SDL_Rect next_step_rect;   
	SDL_Rect switch_rect; 
	SDL_Rect mode_display; 
	Uint8 mode;
	Uint8 alone;
	SDL_Rect alone_choose[8];
	Uint8 hunger;
	SDL_Rect hunger_choose[9];
	float speed;
	SDL_Rect speed_control[3];
} Controler;

void DrawCellPanel(SDL_Window* w, SDL_Renderer* r, Cell* c);
void DrawControlPanel(SDL_Window* w, SDL_Renderer* r, Controler* c);

void CellToStore(SDL_Window* w, SDL_Renderer* r, Cell* c);
void RedrawControlPanel(SDL_Window* w, SDL_Renderer* r, Controler* c);
void RedrawAlonePanel(SDL_Window* w, SDL_Renderer* r, Controler* c);
void RedrawHungerPanel(SDL_Window* w, SDL_Renderer* r, Controler* c);

void CellReproduct(Cell* cell, Controler* control);

void SetTextLocation(SDL_Window* w, SDL_Renderer* r, TTF_Font* font, SDL_Color color, 
	string text, int x, int y);
Uint8 IsInRect(SDL_Event* e, SDL_Rect* r);


SDL_Color color = { 0xaa, 0x70, 0xff };
SDL_Color button_color = { 0x22, 0x33, 0x22 };
TTF_Font* font = NULL;
TTF_Font* button_font = NULL;
TTF_Font* num_font = NULL;

string auto_mode_text =  "自动模式";
string manual_mode_text = "手动模式";
string title_text = "标题";
string switch_text = "切换";
string next_text = "下一个";
string reset_text = "重置";
string start_text = "开始";
string number[11] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
string speed_text = "速度";
string control_icon[3] = { "", "<", ">" };
string des_alone_text = "孤独";
string des_hunger_text = "饥饿";
